   
    <link rel="stylesheet" href="<?php echo $this->module->assetsUrl; ?>/kindeditor/themes/default/default.css" />
	<link rel="stylesheet" href="<?php echo $this->module->assetsUrl; ?>/kindeditor/plugins/code/prettify.css" />
	<script charset="utf-8" src="<?php echo $this->module->assetsUrl; ?>/kindeditor/kindeditor.js"></script>
	<script charset="utf-8" src="<?php echo $this->module->assetsUrl; ?>/kindeditor/lang/zh_CN.js"></script>
	<script charset="utf-8" src="<?php echo $this->module->assetsUrl; ?>/kindeditor/plugins/code/prettify.js"></script>
        <script type="text/javascript" src="<?php echo $this->module->assetsUrl; ?>/datepicker/WdatePicker.js" /></script>



<script >
            
    
            KindEditor.ready(function(K) {
            editor = K.create('#ActivityLinkSignup_content', {
            resizeType : 1,
            items : [
           'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage', 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about']
            });

            });
     </script>
  
<script >

	KindEditor.ready(function(K){
		var editor = K.editor({
			allowFileManager:false,
                        urlType : 'domain',
		});
		K('#Activety_banner_url').click(function() {
                    console.log(111111);
			editor.loadPlugin('image', function() {
				editor.plugin.imageDialog({
					fileUrl : K('#Activety_banner_url1').val(),
					clickFn : function(url, title) {
                                               // var file_url_img = "http://m.kxiche.com";
                                              var file_url_img =  "http://localhost:8087";
						if(url.indexOf("http") > -1){
							K('#Activety_banner_url1').val(file_url_img+url);
                                                        K(' #file_upload_ws').attr('src',file_url_img+url);
                                                        K('#Activety_banner_url1').attr('type','text');
						}else{
							K('#Activety_banner_url1').val(file_url_img+url);
                                                        K('#file_upload_ws').attr('src',file_url_img+url);
                                                         K('#Activety_banner_url1').attr('type','text');
						}  
						editor.hideDialog();
					}
				});
			});
		});
                K('#Activety_min_banner_url').click(function() {
			editor.loadPlugin('image', function() {
				editor.plugin.imageDialog({
					fileUrl : K('#Activety_min_banner_url1').val(),
					clickFn : function(url, title) {
                                               // var file_url_img = "http://m.kxiche.com";
                                              var file_url_img =  "http://localhost:8087";
						if(url.indexOf("http") > -1){
							K('#Activety_min_banner_url1').val(file_url_img+url);
                                                        K('#file_upload_ws_min').attr('src',file_url_img+url);
                                                        K('#Activety_min_banner_url1').attr('type','text');
						}else{
							K('#Activety_min_banner_url1').val(file_url_img+url);
                                                        K('#file_upload_ws_min').attr('src',file_url_img+url);
                                                        K('#Activety_min_banner_url1').attr('type','text');
						}
						editor.hideDialog();
					}
				});
			});
		});
                
                K('#Activety_min_vote_banner_url').click(function() {
                    console.log(111111);
			editor.loadPlugin('image', function() {
				editor.plugin.imageDialog({
					fileUrl : K('#Activety_min_vote_banner_url1').val(),
					clickFn : function(url, title) {
                                               // var file_url_img = "http://m.kxiche.com";
                                              var file_url_img =  "http://localhost:8087";
						if(url.indexOf("http") > -1){
							K('#Activety_min_vote_banner_url1').val(file_url_img+url);
                                                        K('#file_upload_ws_min_vote').attr('src',file_url_img+url);
                                                        K('#Activety_min_vote_banner_url1').attr('type','text');
						}else{
							K('#Activety_min_vote_banner_url1').val(file_url_img+url);
                                                        K('#file_upload_ws_min_vote').attr('src',file_url_img+url);
                                                        K('#Activety_min_vote_banner_url1').attr('type','text');
						}  
						editor.hideDialog();
					}
				});
			});
		});
                
                K('#Activety_vote_banner_url').click(function() {
                    console.log(111111);
			editor.loadPlugin('image', function() {
				editor.plugin.imageDialog({
					fileUrl : K('#Activety_vote_banner_url1').val(),
					clickFn : function(url, title) {
                                               // var file_url_img = "http://m.kxiche.com";
                                              var file_url_img =  "http://localhost:8087";
						if(url.indexOf("http") > -1){
							K('#Activety_vote_banner_url1').val(file_url_img+url);
                                                        K('#file_upload_ws_vote').attr('src',file_url_img+url);
                                                        K('#Activety_vote_banner_url1').attr('type','text');
						}else{
							K('#Activety_vote_banner_url1').val(file_url_img+url);
                                                        K('#file_upload_ws_vote').attr('src',file_url_img+url);
                                                        K('#Activety_vote_banner_url1').attr('type','text');
						}  
						editor.hideDialog();
					}
				});
			});
		});
	});

</script>



<style type="text/css">
    
div.form label.labelForRadio 
{
    display:inline-block;
    width:auto;float:none;
}
</style>
 
 



<div class="row-fluid">
    <div class="span12">
        <!-- BEGIN SAMPLE FORM PORTLET-->  
        
         <div class="alert alert-info">  
            <?php echo Yii::app()->user->getFlash('addform'); ?>  
            </div> 
        <div class="portlet box blue tabbable">
            <div class="portlet-title">
                <div class="caption">
                    <i class="icon-reorder"></i>
                    <span class="hidden-480">活动选择</span>
                </div>
            </div>
            <div class="portlet-body form">
                <div class="tabbable portlet-tabs">
                    <ul class="nav nav-tabs">

                        <?php  switch ($Activity->type_id) {
                                  
                                  case '101':
                                        echo '<li class="active"><a href="#portlet_tab1" data-toggle="tab">报名活动</a></li>';
                                  break;
                                  case '102':
                                       echo  '<li ><a href="#portlet_tab2" data-toggle="tab">投票活动</a></li>';
                                  break;
                              
                                  default:
                                      echo '<li class="active"><a href="#portlet_tab1" data-toggle="tab">报名活动</a></li><li ><a href="#portlet_tab2" data-toggle="tab">投票活动</a></li>';
                                  break;
                                 } 
                         ?>
          
                    </ul>
                    <div class="tab-content">
                        
                        
                        <div class="tab-pane active"  id="portlet_tab1">
                            <!-- BEGIN FORM-->
<!--                            <form action="add" class="form-horizontal" method="post">-->
                                
                                <?php
                                $form = $this->beginWidget(
                                        'CActiveForm', array(
                                    'id' => 'active-form',
                                  // 'enableAjaxValidation'=>true,   
                                   'enableClientValidation'=>true,
                                    'clientOptions' => array(
                                        'validateOnSubmit' => true,
                                    ),
                                    'htmlOptions' => array('enctype' => 'multipart/form-data', 'class' => 'form-horizontal'),
                                        // 'action'=>array('/admin'),
                                ));
                            ?>	
                                <input type="hidden" id="Activity_type_id" name="Activity[type_id]" value="101" class="m-wrap small" />
                                
                                <div class="control-group">
                                    <label class="control-label">标题</label>
                                    <div class="controls">
                                        
                                        <?php echo $form->textField($Activity,'title',array('class'=>'m-wrap large','placeholder'=>"标题"))?>
                                        <?php echo $form->error($Activity, 'title', array('class' => 'label label-danger')); ?>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">活动时间</label>
                                    <div class="controls">
              
                                        <?php echo $form->textField($Activity,'start_time',array('class'=>'m-wrap medium','placeholder'=>"开始时间",'onclick'=>"WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});"))?>
                                        <?php echo $form->textField($Activity,'end_time',array('class'=>'m-wrap medium','placeholder'=>"结束时间",'onclick'=>"WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});"))?>
                                        <?php echo $form->error($Activity, 'start_time', array('class' => 'label label-danger')); ?>
                                        <?php echo $form->error($Activity, 'end_time', array('class' => 'label label-danger')); ?> 
                                    </div>
                                </div>
                                
                                <div class="control-group">
                                    <label class="control-label">活动背景图片</label>
                                    <div class="controls">
                                            <div class="fileupload fileupload-new" data-provides="fileupload">

                                                  <?php if($Activity->isNewRecord)
                                                { ?>
                                                 <img id="file_upload_ws" src="" width="80" height="42" />
                                                <input type="hidden" name='Activity[banner_url]' id="Activety_banner_url1">
                                                <?php } else{?>
                                                <img id="file_upload_ws" src="<?php echo $Activity->banner_url;?>" width="80" height="42" />
                                                <input type="text" value="<?php echo $Activity->banner_url;?>" name='Activity[banner_url]' id="Activety_banner_url1">
                                                <?php }?>
                                                
                                                <input type="button"  id="Activety_banner_url" value='点击上传' />
                                                    
                                            </div> 
                                    </div>
                                </div>
                                
                                <div class="control-group">
                                    <label class="control-label">活动背景缩略图片</label>
                                    <div class="controls">
                                            <div class="fileupload fileupload-new" data-provides="fileupload">
                                                
                                                     
                                               
                                                <?php if($Activity->isNewRecord)
                                                { ?>
                                                 <img id="file_upload_ws_min" src="" width="80" height="42" />
                                                <input type="hidden" name='Activity[min_banner_url]' id="Activety_min_banner_url1">
                                                <?php } else{?>
                                                <img id="file_upload_ws_min" src="<?php echo $Activity->min_banner_url;?>" width="80" height="42" />
                                                <input type="text" value="<?php echo $Activity->min_banner_url;?>" name='Activity[min_banner_url]' id="Activety_min_banner_url1">
                                                <?php }?>
                                                
                                                <input type="button"  id="Activety_min_banner_url" value='点击上传' />

                                               
                                                    
                                            </div> 
                                    </div>
                                </div>
                                
                                
                                
                                
                                <div class="control-group">
                                    <label class="control-label">是否签到</label>
                                    <div class="controls">
                                              <?php echo $form->radioButtonList($ActivityLinkSignup,'is_need_checkin',
                                                        array(1=> '是',2=>'否'), 
                                                        array(
                                                            'separator'=>'&nbsp&nbsp&nbsp&nbsp&nbsp',                                    
                                                            'labelOptions'=>array('class'=>'labelForRadio'),
                                                            'style'=>'margin-left:0',
                                                            ));
                                              ?>
                                    </div>
                                </div>
                                
                                
                                <div class="control-group">
                                    <label class="control-label">是否抽奖</label>
                                    <div class="controls">
                                            <?php echo $form->radioButtonList($ActivityLinkSignup,'is_need_lottery',
                                                        array(1=> '是',2=>'否'), 
                                                        array(
                                                            'separator'=>'&nbsp&nbsp&nbsp&nbsp&nbsp',                                    
                                                            'labelOptions'=>array('class'=>'labelForRadio'),
                                                            'style'=>'margin-left:0',
                                                            ));
                                            ?>
                                        
                                    </div>
                                </div>
                                
                                <div class="control-group" id="lotterytime" style="display:none;" >
                                    <label class="control-label">抽奖时间</label>
                                    <div class="controls">
                                        <input type="text"  id="ActivityLinkSignup_lottery_start_time" value="<?php echo $ActivityLinkSignup->lottery_start_time ?>" placeholder="开始时间" name="ActivityLinkSignup[lottery_start_time]" class="m-wrap medium" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});" />
                                        <input type="text" id="ActivityLinkSignup_lottery_end_time" value="<?php echo $ActivityLinkSignup->lottery_end_time ?>" placeholder="结束时间" name="ActivityLinkSignup[lottery_end_time]" class="m-wrap medium" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});" />
                                        
                                    </div>
                                </div>
                                
                                <div class="control-group">
                                    <label class="control-label">是否报名</label>
                                    <div class="controls">
                                             <?php echo $form->radioButtonList($ActivityLinkSignup,'is_need_signup',
                                                        array(1=> '是',2=>'否'), 
                                                        array(
                                                            'separator'=>'&nbsp&nbsp&nbsp&nbsp&nbsp',                                    
                                                            'labelOptions'=>array('class'=>'labelForRadio'),
                                                            'style'=>'margin-left:0',
                                                            ));
                                            ?>
                                    </div>
                                </div>
                                
                                
                                
                                <div class="control-group" id="signuptime" style="display:none;" >
                                    <label class="control-label">报名时间</label>
                                    <div class="controls">
                                        <input type="text"  id="ActivityLinkSignup_signup_start_time" value="<?php echo $ActivityLinkSignup->signup_start_time; ?>" placeholder="开始时间" name="ActivityLinkSignup[signup_start_time]" class="m-wrap medium" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});" />
                                        <input type="text" id="ActivityLinkSignup_signup_end_time" value="<?php echo $ActivityLinkSignup->signup_end_time; ?>" placeholder="结束时间" name="ActivityLinkSignup[signup_end_time]" class="m-wrap medium" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});" />
                                        
                                    </div>
                                </div>

                                <div class="control-group">
                                    
                                    <label class="control-label">联系人</label>
                                    <div class="controls">
                                       
                                         <?php echo $form->textField($ActivityLinkSignup,'contacts',array('class'=>'m-wrap medium'))?>
                                        <?php echo $form->error($ActivityLinkSignup, 'contacts', array('class' => 'label label-danger')); ?>
                                    </div>
                                </div>
                                <div class="control-group">
                                    
                                    <label class="control-label">联系电话</label>
                                    <div class="controls">
                                   
                                          <?php echo $form->textField($ActivityLinkSignup,'tel',array('class'=>'m-wrap medium'))?>
                                        <?php echo $form->error($ActivityLinkSignup, 'tel', array('class' => 'label label-danger')); ?>
                                    </div>
                                </div>
                               
                              
                                <div class="control-group">
                                    <label class="control-label">活动地址</label>
                                    <div class="controls">
                                   
                                        <?php echo $form->textField($ActivityLinkSignup,'address',array('class'=>'m-wrap span8'))?>
                                        <?php echo $form->error($ActivityLinkSignup, 'address', array('class' => 'label label-danger')); ?>
                                     </div>
                                </div>
                                  
                       
                                <div class="control-group">
                                    <label class="control-label">内容</label>
                                    <div class="controls">
                                        
                                      <?php echo $form->textArea($ActivityLinkSignup,'content',array('class'=>'m-wrap','style'=>'width:800px; height:400px;'))?>
                                    </div>
                                </div>
                                
                                
                                
                                <div class="form-actions ">
<!--                                    <button type="submit" class="btn blue"><i class="icon-ok"></i> 添加活动</button>-->
                                    <?php echo CHtml::SubmitButton('提交',array('class'=>'btn blue','id'=>'add_active'));?>  
                                    <button type="button" class="btn">重填</button>
                                </div>
                            <?php $this->endWidget(); ?>
                            
                            
                            <!-- END FORM-->  
                        </div>
                  
                        <div class="tab-pane " id="portlet_tab2">
                             <?php
                                $form = $this->beginWidget(
                                        'CActiveForm', array(
                                    'id' => 'vote-form',
                                  // 'enableAjaxValidation'=>true,   
                                   'enableClientValidation'=>true,
                                    'clientOptions' => array(
                                        'validateOnSubmit' => true,
                                    ),
                                    'htmlOptions' => array('enctype' => 'multipart/form-data', 'class' => 'form-horizontal'),
                                        // 'action'=>array('/admin'),
                                ));
                            ?>	
                            <input type="hidden" id="Activity_type_id" name="Activity[type_id]" value="102" class="m-wrap small" />
                            <div class="control-group" >
                                     <label class="control-label">标题</label>
                                    <div class="controls">
                                        
                                        <?php echo $form->textField($Activity,'title',array('class'=>'m-wrap large','placeholder'=>"标题"))?>
                                        <?php echo $form->error($Activity, 'title', array('class' => 'label label-danger')); ?>
                                    </div>
                             </div>
                            
                             <div class="control-group">
                                    <label class="control-label">投票结束时间</label>
                                    <div class="controls">
                                        
                                        <?php echo $form->textField($Activity,'start_time',array('class'=>'m-wrap medium','placeholder'=>"开始时间",'onclick'=>"WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});"))?>

                                        <?php echo $form->error($Activity, 'end_time', array('class' => 'label label-danger')); ?> 
                                    </div>
                              </div>
                            
                             <div class="control-group">
                                    <label class="control-label">展示结束时间</label>
                                    <div class="controls">
                                        
                                       
                                        <?php echo $form->textField($Activity,'end_time',array('class'=>'m-wrap medium','placeholder'=>"结束时间",'onclick'=>"WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});"))?>
                  
                                        <?php echo $form->error($Activity, 'end_time', array('class' => 'label label-danger')); ?> 
                                    </div>
                              </div>
                            
                            <div class="control-group">
                                    <label class="control-label">活动背景图片</label>
                                    <div class="controls">
                                            <div class="fileupload fileupload-new" data-provides="fileupload">

                                                  <?php if($Activity->isNewRecord)
                                                { ?>
                                                 <img id="file_upload_ws_vote" src="" width="80" height="42" />
                                                <input type="hidden" name='Activity[banner_url]' id="Activety_vote_banner_url1">
                                                
                                                <?php } else{?>
                                                <img id="file_upload_ws_vote" src="<?php echo $Activity->banner_url;?>" width="80" height="42" />
                                                <input type="text" value="<?php echo $Activity->banner_url;?>" name='Activity[banner_url]' id="Activety_vote_banner_url1">
                                                <?php }?>
                                                
                                                <input type="button"  id="Activety_vote_banner_url" value='点击上传' />
                                                    
                                            </div> 
                                    </div>
                                </div>
                                
                                <div class="control-group">
                                    <label class="control-label">活动背景缩略图片</label>
                                    <div class="controls">
                                            <div class="fileupload fileupload-new" data-provides="fileupload">
                                                
                                                <?php if($Activity->isNewRecord)
                                                { ?>
                                                   <img id="file_upload_ws_min_vote" src="" width="80" height="42" />
                                                   <input type="hidden" name='Activity[min_banner_url]' id="Activety_min_vote_banner_url1">
                                                <?php } else{?>
                                                    <img id="file_upload_ws_min_vote" src="<?php echo $Activity->min_banner_url;?>" width="80" height="42" />
                                                    <input type="text" value="<?php echo $Activity->min_banner_url;?>" name='Activity[min_banner_url]' id="Activety_min_vote_banner_url1">
                                                <?php }?>
                                                
                                                <input type="button"  id="Activety_min_vote_banner_url" value='点击上传' />

                                               
                                                    
                                            </div> 
                                    </div>
                                </div>
                            
                            
                            
                            
                            
                            
                            
                              <div class="control-group col-md-offset-10">
                                   
                                    <div class="controls">
                                        
                                        <a class="btn red" data-toggle="modal" href="#add_vote">添加投票问题</a>
                                    </div>
                              </div>
                           

<!--                            <input type="text" class="m-wrap small" id="input_option"><button class="addoption" id="add_option">增加选项单选</button>-->
                           <div class="portlet box yellow">
                                <div class="portlet-title">
                                        <div class="caption"><i class="icon-coffee"></i>投票问题</div>
                                        <div class="tools">
                                             
<!--                                            <button href="javascript:;" class="add"  onclick="add_question()">添加</button>-->
                   
                                                <a href="javascript:;" class="remove"></a>
                                              
                                        </div>
                                </div>
                                <div class="portlet-body">
                                    <table class="table table-bordered table-hover">
                                            <thead>
                                                    <tr>
                                                            <th>问题</th>
                                                            <th>选项</th>
                                                            <th>操作</th>
                                                    </tr>
                                            </thead>
                                            <tbody id="tbody_vote">
                                                     <?php  
                                                     //p_e($ActivityLinkVoteQ);
                                                     
                                                     if(!isset($ActivityLinkVoteQ->isNewRecord))
                                                     {
                                                         //p(111111);
                                                         
                                                           $ActivityQNum = count($ActivityLinkVoteQ);
                                                           $xuanxiang='';
                                                            foreach ($ActivityLinkVoteQ as $k=>$v){
                                                                $ActivityLinkVoteA = ActivityLinkVoteA::model()->findAllByAttributes(array('vote_q_id' => $v['id'])); 
                                                                
                                                                if($ActivityLinkVoteA){
                                                                    
                                                                     foreach($ActivityLinkVoteA as $kk=>$vv){
                  
                                                                            $xuanxiang .= '<span>'.$vv['sort'].'.'.$vv['a_content']. '</span> ';
                                                                         
                                                                    }
                                                                }
                                                               
                                                                     echo '<tr><td><span>'.$v['sort'].'.'.$v['q_content'].'</span></td><td>'.$xuanxiang.'</td><td><a  onclick="deleteEditCurrentRow(this,'.$v['id'].');">删除问题</a>
                                                                             </td></tr>';
                                                                     
                                                                $xuanxiang='';
                                                            }
                                                            echo '<input type="hidden" id="ActivityLinkVoteQ_del" name="ActivityLinkVoteQ[del]" value="">';
                                                     }
                                                     ?>
                                            </tbody>
                                    </table>
                                    
                                    
                                    
                                    
                                    
                                </div>
                        </div>
                            
                            
                             <div class="form-actions">
                                    <button type="submit"  id="submit_vote" class="btn blue"><i class="icon-ok"></i> 添加活动</button>
                                    <button type="reset" class="btn" >重填</button>
                              </div>
                            
                            <?php $this->endWidget(); ?>	

                        </div>
                    
                    
                    </div>
                </div>
            </div>
        </div>
        <!-- END SAMPLE FORM PORTLET-->
    </div>
</div>
<!-- END PAGE CONTENT--> 

      


<div id="add_vote" class="modal hide fade" tabindex="-1" data-width="560">
                <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                        <h3>发起投票</h3>
                </div>
                <div class="modal-body">
                        <div class="row-fluid">
                                <div class="span6">
                                       <input type="text" placeholder="请填写问题" id="question" class="span12 m-wrap">
                                                  
                                            <label class="radio">
                                                <input type="radio" id="ActivityLinkVoteQ_type_id_tmp"   checked="checked" value="31" />单选
                                            </label>
                                      <div class="controls" id="answer_input_div"> 
                                          <?php if(isset($ActivityQNum)){?>
                                            <input type="text" id="answer<?php echo $ActivityQNum; ?>" placeholder="请填写答案"  name="ActivityLinkVoteA[answer][0]" class="span12 m-wrap">
                                            <input type="text" id="answer<?php echo $ActivityQNum+1; ?>" placeholder="请填写答案"  name="ActivityLinkVoteA[answer][1]" class="span12 m-wrap">
                                          <?php }else { ?>
                                            <input type="text" id="answer1" placeholder="请填写答案"  name="ActivityLinkVoteA[answer][1]" class="span12 m-wrap">
                                            <input type="text" id="answer2" placeholder="请填写答案"  name="ActivityLinkVoteA[answer][2]" class="span12 m-wrap">
                                          <?php } ?>  
                                            <a class="blue small" id="a_add_vote" onclick="add_vote(this)">[+添加选项]</a>
                                            <a class="blue small" id="a_add_vote" onclick="del_vote(this)">[-删除选项]</a>
                                      </div>
                                </div>
                        </div>
                </div>
                <div class="modal-footer">
                        <button type="button small" data-dismiss="modal"  onclick="colse('#add_vote')" class="btn">取消</button>
                        <button type="button small" id="add_vote_ok"  class="btn blue">保存</button>
                </div>
</div>
 

<script type="text/javascript">
   
   function colse(divid){
  //var a=$('#table-user-prepaid_c0_0').val();
    $(divid).modal('hide');
}

   
    $('#ActivityLinkSignup_is_need_signup_0').click(function(){
       
        if($(this).val()==1){
            $("#signuptime").attr("style","display:bolck");
            
        }
    });
    
    $('#ActivityLinkSignup_is_need_signup_1').click(function(){
      
        if($(this).val()==2){
            $("#signuptime").attr("style","display:none");
            
        }
    });
    
    //抽奖
    $('#ActivityLinkSignup_is_need_lottery_0').click(function(){
       
        if($(this).val()==1){
            $("#lotterytime").attr("style","display:bolck");
            
        }
    });
    
    $('#ActivityLinkSignup_is_need_lottery_1').click(function(){
      
        if($(this).val()==2){
            $("#lotterytime").attr("style","display:none");
            
        }
    });
    
    
    
     
     var a_i =3;//答案数组下标
     var a_j= 3;////答案id
     var a_q= <?php echo isset($ActivityQNum)?$ActivityQNum:0;?>;//提交问题数组下标
     var a_a= 1;//提交答案 数组下标
     var isNum =a_q;
    function add_vote(obj) {
        
        
      var htmloptions ='';
        htmloptions += '<input type="text" id="answer'+a_j+'" placeholder="请填写答案" name="ActivityLink[answer]['+a_i+']" class="span12 m-wrap">';
        $(obj).before(htmloptions); 
        var htmloptions = '';
        a_j = a_j+1;
        a_i = a_i+1;
      
       
    }
    
     function del_vote(obj){
        
        if(a_j >2 && a_i>2){
            $("#answer_input_div input[type='text']:last").remove();   
            a_j = a_j-1;
            a_i = a_i-1;
        }
    
    }
    
    
                                   
    $('#add_vote_ok').click(function(){
      
            a_q = a_q+1;
        
        
         console.log("a_q:"+a_q);
        var htmlanswer ='';
       
       $("#answer_input_div input").each(function(){
           htmlanswer +=''+a_a+'.<input type="text" style="width:70px;" name="ActivityLinkVoteA[a_content]['+a_q+']['+a_a+']" value="'+$(this).val()+'" />  ';
           a_a =a_a+1;
       });
       a_a=1;
       
        var qhtml = $("#question").val(); 
        var q_type_id=$("#ActivityLinkVoteQ_type_id_tmp").val();
        var htmloptions ='';
        htmloptions += '<tr><td>'+a_q+'.<input type="text"  name="ActivityLinkVoteQ[q_content]['+a_q+']" value="'+qhtml+'"></td><td>'+htmlanswer+'</td><td><a  onclick="deleteAddCurrentRow(this);">删除问题</a><input type="hidden"  name ="ActivityLinkVoteQ[type_id]" value="'+q_type_id+'" ></td></tr>';
         //a_q =a_q+1;
        $('#tbody_vote').append(htmloptions); 
        $("#question").empty();
       
    });
    
  
    
   function deleteEditCurrentRow(obj,id){
       
       if(a_q >1 ){
          
           // a_a = a_a-1;
            if(a_q >isNum)
                a_q = a_q-1;
            console.log("a_q:"+a_q);
            var tr=obj.parentNode.parentNode;
            var tbody=tr.parentNode;
             
            tbody.removeChild(tr);
            
            var V_D=$('#ActivityLinkVoteQ_del').val();
            $('#ActivityLinkVoteQ_del').val(id+','+V_D);
            
        }else{
            alert("无法删除至少保留一个问题！");
            
        }
           
           
            
    }
    
    function deleteAddCurrentRow(obj){
       
       if(a_q >1 ){
          
           // a_a = a_a-1;
            if(a_q >isNum)
                a_q = a_q-1;
            console.log("a_q:"+a_q);
            var tr=obj.parentNode.parentNode;
            var tbody=tr.parentNode;
             
            tbody.removeChild(tr);
            
//            var V_D=$('#ActivityLinkVoteQ_del').val();
//            $('#ActivityLinkVoteQ_del').val(id+','+V_D);
            
        }else{
            alert("无法删除至少保留一个问题！");
            
        }
           
           
            
    }
    
    
    
    
   $(document).ready(function() {    
       
    var type_id = <?php echo $Activity->type_id?$Activity->type_id:0; ?>;
    console.log(type_id);
    
    
    
      switch(type_id)
      {
       
         case 101:
             
            if( $(':radio[name="ActivityLinkSignup[is_need_lottery]"]').eq(0).attr("checked"))
            {
                $("#lotterytime").attr("style","display:bolck");
            }

            if( $(':radio[name="ActivityLinkSignup[is_need_signup]"]').eq(0).attr("checked"))
            {
                $("#signuptime").attr("style","display:bolck");
            }
             
             
             $('#portlet_tab1').attr('class','tab-pane active');
             $('#portlet_tab1').attr('style','display:bolck');
             $('#portlet_tab2').removeAttr('class');
             $('#portlet_tab2').attr('style','display:none');
             
         break;
         
        case 102:
              
               $('#portlet_tab2').attr('class','tab-pane active');
               $('#portlet_tab2').attr('style','display:bolck');
               $('#portlet_tab1').removeAttr('class');
               $("#portlet_tab1").attr("style","display:none");
            break;
        default :
         
      }
       
       

   });
   
   $('#add_active').click(function(){
       
         $('#active-form').submit();
         
        // alert(1111);
       
   });
   
//    $('#submit_vote').click(function(){
//       
//         $('#vote-form').submit();
//         
//        // alert(2222);
//        // return false;
//   });
   
   
    
    

</script>

